package com.rjyb.dyxz.servlet;

import com.rjyb.dyxz.dao.IUserDao;
import com.rjyb.dyxz.dao.Impl.UserDaoImpl;
import com.rjyb.dyxz.pojo.User;
import com.rjyb.dyxz.service.IUserService;
import com.rjyb.dyxz.service.Impl.UserServiceImpl;
import com.rjyb.dyxz.unit.BaseServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@WebServlet("/UserServlet")
public class UserServlet extends BaseServlet {
   //这里与前端交互
    public void enroll(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String userName = req.getParameter("Username");
        String name = req.getParameter("name");
        String password = req.getParameter("password");
        String password1 = req.getParameter("password1");
        String sex = req.getParameter("sex");
        String age = req.getParameter("age");
        String email1 = req.getParameter("email1");
        String address = req.getParameter("address");
        String phone1 = req.getParameter("phone1");
        String drawImg = req.getParameter("DrawImg");
        User user = new User();
        user.setUserName(userName);
        user.setName(name);
        user.setUserPwd(password);
        user.setSex(sex);
        user.setAge(age);
        user.setEmail(email1);
        user.setAddress(address);
        user.setPhone(phone1);
        IUserService userService = new UserServiceImpl();
        userService.enroll(drawImg,password1,user,req,resp);
    }
}
